# coding:utf-8
import unittest as unittest
import os
from configparser import ConfigParser
from utils.settting import ensure_path_sep
from utils.logger import Logger


class BaseTestCase(unittest.TestCase):
    parse = ConfigParser()

    env_base = "pro"

    def read(self, section, option):
        if self.env_base == 'test':

            self.parse.read(ensure_path_sep("/configs/test.ini"), encoding="utf-8")
        elif self.env_base == 'pre':

            self.parse.read(ensure_path_sep("/configs/pre.ini"), encoding="utf-8")
        elif self.env_base == 'pro':

            self.parse.read(ensure_path_sep("/configs/pro.ini"), encoding="utf-8")

        elif self.env_base == 'pre_copy':

            self.parse.read(ensure_path_sep("/configs/pre_copy.ini"), encoding="utf-8")

        elif self.env_base == 'dev':

            self.parse.read(ensure_path_sep("/configs/dev.ini"), encoding="utf-8")
        else:
            print("没有该环境配置文件")
        name = self.parse.get(section, option)

        return name
